package com.dxy.app.act_widget;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.annotation.Nullable;
import android.util.Log;
import com.dxy.app.R;
import com.dxy.app.widget.draw.WaveView;

/**
  *Created by duxingyu on 2017/8/1.15:54
  *Email:
  *Description:画布界面
  **/

public class CanvasActivity extends Activity {

  private WaveView waveView;
  @Override protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_canvas);

    waveView = (WaveView) findViewById(R.id.wv);


    //startWave();
    handler.postDelayed(()->waveView.setCurPercent(0.3f),3000);
    //waveView.postDelayed(()->test(),3000);
  }
  private void test(){
    new Thread(()->{
      int i=0;
      while(i<50000){
        i++;
        Log.i("TAG_", "test: "+i);
      }
    }).start();
  }
  private void startWave(){
    new Thread(()->{
      try {
        Thread.sleep(3000);
      } catch (InterruptedException e) {
        e.printStackTrace();
      }
      int x =0;
      while(x<9){
        x+=1;
        handler.sendEmptyMessage(0);
        try {
          Thread.sleep(1000);
        } catch (InterruptedException e) {
          e.printStackTrace();
        }
      }
    }).start();
  }
  Handler handler =new Handler(){
    private float percent=1;
    @Override public void handleMessage(Message msg) {
      percent+=1;
      waveView.setCurPercent(percent/10f);
    }
  };
}
